

<%var body = {%>

<form method="post" class="eova-form">
	<div class="eova-form-field">
		<label class="eova-form-label red">数据源</label>
		<#combo id="ds" name="ds" value="main" width="400" />
	</div>
	<div class="eova-form-field">
		<label class="eova-form-label red">元类型</label>
		<#combo id="type" name="type" value="table" width="400" />
	</div>
	<div class="eova-form-field">
		<label class="eova-form-label red">元数据表</label>
		<#find id="table" name="table" url="/meta/find/main-table" width="400" />
	</div>
	<div class="eova-form-field" id="tr_pk">
		<label class="eova-form-label">视图主键</label>
		<#text id="pk" name="pk" value="" placeholder="仅纯查询视图可不填主键" width="400" />
	</div>
	<div class="eova-form-field">
		<label class="eova-form-label red">元对象名称</label>
		<#text id="name" name="name" placeholder="对象中文描述" width="400" />
	</div>
	<div class="eova-form-field">
		<label class="eova-form-label red">元对象编码</label>
		<#text id="code" name="code"  placeholder="xxx_xxx_xxx" width="400" />
	</div>
</form>

<script type="text/javascript">
	$(function(){
		var $type = $('#ds').eovacombo({
			json : [
				<%for(ds in dataSources){%>
			{id:'${ds.key}', cn : '${ds.key}'},
			<%}%>
	],
		onChange: function (oldValue, newValue) {
			valueChange();
		}
	}).reload();

		var $type = $('#type').eovacombo({
			json : [
				{id:'table', cn : 'Table'},
				{id:'view', cn : 'View'}
			],
			onChange: function (oldValue, newValue) {
				valueChange();
			}
		}).reload();

		//init
		valueChange();
	});

	// 元类型变更时级联变更元数据表查找框URL
	var valueChange = function(){
		var type = $('#type').eovacombo().getValue();
		var url = '/meta/find/' + $('#ds').eovacombo().getValue() + '-' + type;
		$('#table').eovafind({url: url}).setValue('');

		if(type == 'view'){
			$('#tr_pk').show();
		} else {
			$('#tr_pk').hide();
		}
	}
</script>

<script type="text/javascript">
	// ------------------------- 动态参数配置
	var $form = $('.eova-form');
	var action = '/meta/doImports';
	var msg = '导入元数据成功';
	// ------------------------- 动态参数配置

	// 确认按钮回调
	var btnSaveCallback = function($dialog, ID, $$) {
		submitForm($$, ID, $form, action, msg);
	};
</script>

<%};include("/eova/layout/form.html",{'title' : '导入元数据', 'layoutContent' : body, 'isEditor' : false}){}%>